<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <script src="../react/react.development.js"></script>
  <script src="../react/react-dom.development.js"></script>
  <script src="../react/babel.min.js"></script>

  <script type="text/babel">
    class App extends React.Component {
      constructor(props) {
        super(props)
        this.state = {
          isLogin: true
        }
      }
      render() {
        const { isLogin } = this.state
        let welcome = null;
        let btnText = "退出";
        {/*iv-show效果*/ }
        const isShow = isLogin ? 'block' : 'none'
        if (isLogin) {
          welcome = <h2>欢迎回来~</h2>
          btnText = "退出";
        } else {
          welcome = <h2>请先登录~</h2>
          btnText = "登录";
        }
        return (
          <div>
            <div>
              我是div元素
            </div>
            {welcome}
            <button onClick={e => this.loginClick()}>{isLogin ? "退出" : "登入"}</button>
            <hr />
            <h2>{isLogin ? '你好啊GH' : null}</h2>
            <h2 style={{ display: isShow }}>您好啊，YZ</h2>
          </div>
        )
      }
      loginClick() {
        console.log('111');
        this.setState({
          isLogin: !this.state.isLogin
        })
      }
    }
    ReactDOM.render(<App />, document.getElementById('app'))
  </script>
</body>

</html>